package cn.yours.web.result;

/**
 * 2024/6/5 14:51
 * wuhon
 * cn.kong.web.result
 * spring-elfinder
 */
public class Result<T> {
    private int code;
    private String message;
    private T data;


    public static <T> Result<T> success(String message,T data){
        Result<T> result = new Result<>(200, message, data);
        return result;
    }

    public static <T> Result<T> success(){
        return new Result<>(200,"操作成功",null);
    }

    public static <T> Result<T> error(int code, String message){
        return new Result<>(code, message,null);
    }
    public Result(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Result() {
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
